/*
 * @Description: 短信发送配置
 * @Version: 2.0
 * @Author: Symbol_Yang
 * @Date: 2022-08-02 10:49:26
 * @LastEditors: Symbol_Yang
 * @LastEditTime: 2022-10-27 15:29:09
 */
const mongoose = require('mongoose')
const {Schema} = mongoose
//


var ShortMsgSendConfigSchema = new Schema({
    
    short_msg_id: { type: Schema.Types.ObjectId, ref: 'short_msg', required: true }, // 短信模板

    type: {type: Number, enum: [1,2]}, // 类型 1、温度传感器 2、气体传感器

    warning_num: { type: Number, required: true }, // 警戒线
    
    send_setting: { type: Number, required: true, enum: [1,2], default: 1 }, // 首次发送触机制 1、越线即发送；2、1分钟内出现5次预警即发送

    pause_time: {type: Number, required: true, default: 5}, // 停顿时间  |min

    sort: { type: Number, required: false  }, // 优先级

    create_at: {type: Date, default: Date.now, index: -1},
    update_at: {type: Date, default: Date.now},
})

ShortMsgSendConfigSchema.pre('save', function (next) {
    let now = new Date()
    this.update_at = now
    next()
})
mongoose.model('short_msg_send_config', ShortMsgSendConfigSchema)
module.exports = ShortMsgSendConfigSchema
